From c00c76705c14c35aa43f663743827e511968fd12 Mon Sep 17 00:00:00 2001
From: Daniel Kolesa <daniel@octaforge.org>
Date: Wed, 6 Apr 2022 01:03:43 +0200
Subject: [PATCH 03/19] llvm: musl workarounds

---
 llvm/include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
 llvm/lib/Support/Unix/DynamicLibrary.inc       | 2 +-
 llvm/utils/unittest/googletest/src/gtest.cc    | 1 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
index 7bfda0124..8c0bc6054 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -16,6 +16,15 @@
 #include "llvm/IR/PassManager.h"
 #include "llvm/Pass.h"
 
+#undef fopen64
+#undef fseeko64
+#undef fstat64
+#undef fstatvfs64
+#undef ftello64
+#undef lstat64
+#undef stat64
+#undef tmpfile64
+
 namespace llvm {
 
 template <typename T> class ArrayRef;
diff --git a/llvm/lib/Support/Unix/DynamicLibrary.inc b/llvm/lib/Support/Unix/DynamicLibrary.inc
index a2a379963..2f86c470c 100644
--- a/llvm/lib/Support/Unix/DynamicLibrary.inc
+++ b/llvm/lib/Support/Unix/DynamicLibrary.inc
@@ -102,7 +102,7 @@ static void *DoSearch(const char* SymbolName) {
 
 // This macro returns the address of a well-known, explicit symbol
 #define EXPLICIT_SYMBOL(SYM) \
-   if (!strcmp(SymbolName, #SYM)) return &SYM
+   if (!strcmp(SymbolName, #SYM)) return (void *)&SYM
 
 // Under glibc we have a weird situation. The stderr/out/in symbols are both
 // macros and global variables because of standards requirements. So, we
diff --git a/llvm/utils/unittest/googletest/src/gtest.cc b/llvm/utils/unittest/googletest/src/gtest.cc
index a5b4e5ac7..b2235448c 100644
--- a/llvm/utils/unittest/googletest/src/gtest.cc
+++ b/llvm/utils/unittest/googletest/src/gtest.cc
@@ -114,6 +114,7 @@
 
 #if GTEST_CAN_STREAM_RESULTS_
 # include <arpa/inet.h>  // NOLINT
+# include <sys/socket.h>  // NOLINT
 # include <netdb.h>  // NOLINT
 # include <sys/socket.h>  // NOLINT
 # include <sys/types.h>  // NOLINT
-- 
2.37.3

